#!/usr/bin/env php
<?php

define("ROOT_PATH", __DIR__ . DIRECTORY_SEPARATOR);
require ROOT_PATH . 'vendor/autoload.php';

use Symfony\Component\Console\Application;

// 载入配置信息
require_once ROOT_PATH . 'bootstrap/config.php';
date_default_timezone_set($_ENV['app_timezone']);

// 控制台实例化
$app = new Application(ucfirst($_ENV['app_name'] ?? '') . ' Command Management Console', '1.0');

// 控制台可用服务命令 和 自动发现命令实例
$dispatch = require ROOT_PATH . 'console/dispatch.php';
$dispatch($app);
unset($dispatch);

// 定义DB门面
Illuminate\Support\Facades\DB::setFacadeApplication([
    'db' => App\Components\Providers::database()->getDatabaseManager(),
    'date' => new Carbon\Factory(['timezone' => $_ENV['app_timezone']]),
]);
// 注册LOG全局变量
Monolog\Registry::addLogger(App\Components\Providers::logger('cmc'), 'cmc');

$app->run();
